import { ref } from "vue";

interface User {
  email: string;
  password: string;
}

interface Rules {
  email: {
    type: string;
    message: string;
    required: boolean;
    trigger: string;
  }[];
  password: ({
    required: boolean;
    message: string;
    trigger: string;
    min?: undefined;
    max?: undefined;
  } | {
    min: number;
    max: number;
    message: string;
    trigger: string;
    required?: undefined;
  })[];
}

export const loginUser = ref<User>({
	email: "",
	password: "",
})

export const rules = ref<Rules>({
	email: [
		{ type: "email", message: "请输入正确的邮箱地址", required: true, trigger: 'blur' }
	],
	password: [
		{ message: "密码不能为空", required: true, trigger: 'blur' },
		{ min: 6, max: 30,  message: "密码长度在6-30之间", trigger: 'blur' }
	]
})